﻿@model IEnumerable<VehicleManagement.Models.CarInsure>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="@Url.Content("~/Scripts/SetPagingScript.js")" type="text/javascript"></script>
<script type="text/javascript">
//    $(function () {
//        //        alert($.query.get("DriverName"));
//        $.post("/CarInsure/GetPagingInfo", {},
//            function (data) {
//                $("#TotalItems").text(data.TotalItems);
//                $("#ItemsPerPage").text(data.ItemsPerPage);
//                $("#TotalPages").text(data.TotalPages);
//                $("#CurrentPage").text(data.CurrentPage);
//            });
    //    });
    $(function () {
        if ($.query.get("Page") != "") {
            $("#Page").val($.query.get("Page"));
        }
        else {
            $("#Page").val(1);
        }

        if ($.query.get("carNum") != "" && !$.query.get("carNum")) {
            $("input[name='carNum']").val($.query.get("carNum"));
        }

        if ($.query.get("insureType") != "" && !$.query.get("insureType")) {
            $("input[name='insureType']").val($.query.get("insureType"));
        }

        if ($.query.get("apploval") != "" && !$.query.get("apploval")) {
            $("input[name='apploval']").val($.query.get("apploval"));
        }

        $.get("/CarInsure/GetPagingInfo",
            {
                carNum: $("input[name='carNum']").val(),
                insureType: $("input[name='insureType']").val(),
                apploval: $("input[name='apploval']").val(),
                Page: $("#Page").val()
            },
            function (data) {
                $("#TotalItems").text(data.TotalItems);
                $("#ItemsPerPage").text(data.ItemsPerPage);
                $("#TotalPages").text(data.TotalPages);
                $("#CurrentPage").text($("#Page").val());
            }
        );
        SetPagingOperation();
    });
    function Delete(id) {
        if (confirm("你确认删除这条保险记录吗?")) {
            $.post("/CarInsure/Delete", "id=" + id, function (ret) {
                if (ret.Result == "true") {
                    alert(ret.Message);
                    window.location.reload();
                }
                else {
                    alert(ret.Message);
                }
            }, "json");
        }
    }
</script>
@*<h2>Index</h2>*@
<div class="mas">
    <div class="toptitle">
        司机负责人管理平台
    </div>
    @*<div class="car"></div>*@
    @Html.Partial("_PartviewDriverManager")
    <div class="rightshow">
        <div class="classifyinfo">
            <div class="system-location">
                <a>司机负责人管理系统</a>>><a>车辆保险</a>
            </div>
            <div class="system-Userinfo">
                <span class="space">当前用户:</span><a>张测试</a><span class="space">部门:</span><a>技术部</a><a
                    class="space">退出</a>
            </div>
            <div class="clear">
            </div>
        </div>
        <div class="apply_content">
            <div class="contrlcar">
            </div>
            <div class="createrecord">
                <div class="createrecord_bc">
                    <div class="createrecord_bc1">@Html.ActionLink("添加新记录", "Create")</div>
                </div>
            </div>
            <div class="apply_cn1">
                <div class="apply_cn1-item">
                    记录筛选：
                </div>
                @using (Html.BeginForm("Index", "CarInsure", FormMethod.Get, new { id = "SearchForm" }))
                {
                    @Html.Hidden("Page");
                    <div class="apply_cn1-item1">
                        <input id="key" name="carNum" type="text" value="车牌号" class="ipt-2" /><input type="submit"
                            value="" class="btn-2" />
                    </div>
                    <div class="apply_cn1-item1">
                        <input id="key2" name="insureType" type="text" value="保险类别" class="ipt-2" /><input
                            type="submit" value="" class="btn-2" />
                    </div>
                    <div class="apply_cn1-item1">
                        <select id="sort-bar-itemSelect3" name="apploval">
                            <option selected="selected">有无审批</option>
                            <option>未审批</option>
                            <option>已审批</option>
                        </select>
                    </div>
                    <div class="apply_cn1-item2">
                        <input type="submit" value="搜索" />
                    </div>
                }
                <div class="clear">
                </div>
            </div>
        </div>
        <table id="applytable" cellspacing="0">
            <tr>
                <th>
                    车牌号
                </th>
                <th>
                    保险公司
                </th>
                <th>
                    保险类型
                </th>
                <th>
                    日期
                </th>
                <th>
                    经办人
                </th>
                <th>
                    编辑
                </th>
            </tr>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @item.CarNumber
                    </td>
                    <td>
                        @item.InsureCom
                    </td>
                    <td>
                        @item.Insuretype
                    </td>
                    <td>
                        @String.Format("{0:yyyy.MM.dd}", item.InsureDate)
                    </td>
                    <td>
                        @item.InsureAgent
                    </td>
                    <td id="myapplytabletd">
                        <div class="myapplytable_dt">
                            @Html.ActionLink("修改", "Edit", new { id = item.CarInsureID })
                        </div>
                        <div class="myapplytable_dt">
                            @Html.ActionLink("详细", "Details", new { id = item.CarInsureID })
                        </div>
                        <div class="myapplytable_dt">
                            <a href="javascript:void(0)" onclick="Delete(@item.CarInsureID)">删除</a>
                        </div>
                    </td>
                </tr>
            }
        </table>
        <div>
    共<span id="TotalItems"></span>条记录， 每页显示<span id="ItemsPerPage"></span>条， 共<span id="TotalPages"></span>页，
    当前第<span id="CurrentPage"></span>页 <a id="FirstPage" href="javascript:void(0)">首页</a>
    <a id="PrevPage" href="javascript:void(0)">上一页</a> <a id="NextPage" href="javascript:void(0)">
        下一页</a> <a id="LastPage" href="javascript:void(0)">末页</a> <span>跳转到</span>
    <input type="text" id="PageToGo" />
    <input type="button" id="GoToPage" value="Go" />
</div>
    </div>
    <div class="clear">
    </div>
</div>